public class Test1 {
    public static int missingNumber(int[] arr) {//https://leetcode.cn/problems/missing-number-lcci/description/
        if(arr==null){
            return -1;
        }else{
            int sum=(0+ arr.length)*(arr.length+1)/2;
            int tmp=0;
            for(int i=0;i< arr.length;i++){
                tmp+=arr[i];
            }
            int ret=sum-tmp;
            return ret;
        }
    }
    public static void main(String[] args) {
        int[] nums={3,0,1};
        int ret=missingNumber(nums);
        if(ret==-1){
            System.out.println("数组为空");
        }else{
            System.out.println(ret);
        }

    }
}
